﻿using System;
using System.Diagnostics;
using System.Windows.Forms;

namespace ALDIOrganizer
{
    public partial class Program
    {
        public static User Logged;
        private static EventLog _log;

        public static void CloseLog()
        {
            _log.Close();
        }

        public static void LogError(string pEntry, Exception pException)
        {
            if (pException != null)
            {
                pEntry += String.Concat(": ", pException.Message, Environment.NewLine);
                pEntry += String.Concat("TargetSite: ", pException.TargetSite, Environment.NewLine, Environment.NewLine);
                pEntry += String.Concat("StackTrace: ", pException.StackTrace, Environment.NewLine);
            }
            _log.WriteEntry(
                pEntry,
                EventLogEntryType.Error);
        }

        private void InitializeLog()
        {
            _log = new EventLog("Application") { Source = Application.ProductName };
        }
    }
}
